package com.saver.view.office.controller;

import com.saver.office.register.OfficeRegister;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/view")
public class OpenController {

    //以只读打开
    @PostMapping("/open")
    public Map<String,String> readOnly(HttpServletRequest request, @RequestBody Entity entity) {
        OfficeRegister register = OfficeRegister.getInstance();
        String type = entity.getType();

        register.setKey("RbK4XF4nTWUWRwwq");

        StringBuffer url = request.getRequestURL();
        String s = url.delete(url.length() - request.getRequestURI().length(), url.length()).toString();
        register.setRequestUrl(s + "/office/");
        String register1 = register.register(entity.getPath(), Boolean.valueOf(type));
        HashMap<String, String> stringStringHashMap = new HashMap<>();
        stringStringHashMap.put("msg", register1);
        return stringStringHashMap;
    }

}
